package com.fr.privilege.ui;

import com.fr.base.StringUtils;
import com.fr.base.core.util.TemplateUtils;
import com.fr.web.core.WebUtils;
import com.fr.web.core.service.PlatformService;
import com.fr.web.platform.PlatformUtils;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class DefaultLoginoutUI extends LoginoutUI
{
  public void redirect2LoginUI(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse, String paramString)
    throws Exception
  {
    PlatformUtils.redirect(paramHttpServletResponse, createURL(paramHttpServletRequest, paramHttpServletResponse, paramString));
  }

  public String createURL(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse, String paramString)
    throws Exception
  {
    Map localMap = WebUtils.createTemplateMap(paramHttpServletRequest);
    String str1 = TemplateUtils.render(generateCuteURL(paramHttpServletRequest), localMap);
    String str2 = WebUtils.getHTTPRequestParameter(paramHttpServletRequest, "op");
    HttpSession localHttpSession = paramHttpServletRequest.getSession(true);
    if ((str2 == null) || (!(str2.startsWith("auth_"))))
      localHttpSession.setAttribute("fr_from", WebUtils.getOriginalURL(paramHttpServletRequest));
    if (StringUtils.isNotEmpty(paramString))
      localHttpSession.setAttribute("fr_error", paramString);
    str1 = str1 + "&_=" + System.currentTimeMillis();
    return str1;
  }

  private String generateCuteURL(HttpServletRequest paramHttpServletRequest)
  {
    String str1 = "${servletURL}?op=auth_loginui";
    String str2 = WebUtils.getHTTPRequestParameter(paramHttpServletRequest, "op");
    if ((StringUtils.isNotBlank(str2)) && (PlatformService.getInstance().accept(str2)))
      str1 = "${servletURL}?op=auth_loginplatformui";
    return str1;
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }
}